package com.dylan.magic.guava.event.bus;

import com.alibaba.fastjson.JSON;
import com.dylan.magic.common.util.SleepUtil;
import com.google.common.eventbus.DeadEvent;
import com.google.common.eventbus.Subscribe;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

/**
 * @author : ankang
 * @date : 2020/3/3 20:57
 * @Description :
 */
@Service
@Slf4j
public class MyEventListener {

    @Subscribe
    public void monitor(MyMessage myMessage) {
        log.info("监听事件:{}", JSON.toJSONString(myMessage));
        SleepUtil.sleep(2, TimeUnit.SECONDS);
    }

    @Subscribe
    public void deadEvent(DeadEvent deadEvent) {
        log.info("未监听的事件:{}", deadEvent);
    }
}
